#include"gui_box.h"
#include"gui_color.h"
#include"gui_container.h"
#include<stdio.h>

gui_spirit_t *gui_box_create(gui_box_orientation_t orientation,int w,int h,int spacing)
{
    gui_box_t *box=malloc(sizeof(gui_box_t));
    if(!box)   
        return NULL;
    
    gui_spirit_t *spirit=&box->spirit;
    box->orientation=orientation;
    gui_spirit_init(spirit,0,0,w,h);
    spirit->surface=gui_surface_create(w,h);
    if(!spirit->surface)
    {
        free(box);
        return NULL;
    }
    gui_surface_rectfill(spirit->surface,0,0,w,h,GUI_WHITE);
    gui_spirit_set_type(spirit,GUI_SPIRIT_TYPE_BOX);
    spirit->style.font_align=GUI_ALIGN_CENTER;
    spirit->container=gui_container_create(spirit);
    spirit->style.background_color=GUI_WHITE;
    if(!spirit->container)
    {
        free(box);
        return NULL;
    }
    return spirit;
}
